/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef EMULEX_INTERFACE_PORT_H
#define EMULEX_INTERFACE_PORT_H

#include <imu/imu.h>
#include <mc/engine.h>
#include <pldm_over_mctp/pldm_over_mctp_emulex.h>

#include "interface/network_port.h"
#include "interface/network_port/link_info.h"
#include "interface/network_port/fibrechannel.h"
// #include "interface/network_port/lldp_receive.h"

namespace dev {
using pldm_over_mctp_emulex_ptr = std::shared_ptr<pldm_over_mctp_emulex>;

class emulex_port : public mc::engine::object<emulex_port> {
public:
    MC_OBJECT(emulex_port, "NicPort", "NicPort/${PortId}",
              (NetworkPort)(NetworkPort_LinkInfo)(NetworkPort_FibreChannel))
    emulex_port()  = default;
    ~emulex_port() = default;
    bool start();
    bool stop();
    bool init(mc::mutable_dict& csr_object, const mc::dict& connector);

    bool start_pldm_protocol(pldm_over_mctp_emulex_ptr pldm_over_mctp, mc::milliseconds interval);
    void stop_pldm_protocol();
    bool update_port_bdf(imu_pcie_device_req_t& pcie_device_info);
    bool verify_did_vid_svid_sdid(imu_pcie_device_req_t& pcie_device_info);
    NetworkPort             m_network_port;
    NetworkPort_LinkInfo    m_network_port_link_info;
    NetworkPort_FibreChannel    m_network_port_fibrechannel;
    
    std::unique_ptr<imu> m_imu;
};

} // namespace dev

#endif